<!DOCTYPE html>
<html
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        >

<h:head>
    <title>Crime Qualificator</title>
    <h:outputStylesheet library="css" name="typeface.css"/>
    <h:outputStylesheet library="css" name="common.css"/>
    <h:outputStylesheet library="css" name="bootstrap.css"/>
    <h:outputStylesheet library="css" name="login.css"/>
    <f:loadBundle basename="com.dataart.training.crimequalification.facesutils.messages"
                  var="msgs"></f:loadBundle>
    <f:loadBundle basename="com.dataart.training.crimequalification.facesutils.configurations"
                  var="conf"></f:loadBundle>
</h:head>

<f:view>

<f:metadata>
    <f:event type="preRenderView" listener="#{crimeComponentsBean.noTaskChosenRedirect}"/>
</f:metadata>

<h:body styleClass="body">
<ui:include src="/views/navbar.xhtml"/>

<h:panelGroup id="taskchosen" rendered="#{not crimeComponentsBean.solutionSubmitted}">
<div class="container">

<div class="well" style="position: fixed; width: 940px">

    <div class="alert alert-info" >
        <p><strong>&#160;&#160;Задача №#{crimeComponentsBean.task.taskId}</strong>
            <br/>
            <br/>
            &#160;&#160;&#160;&#160;#{crimeComponentsBean.task.taskText}</p>
    </div>

    <h:form>
        <h:commandButton action="#{crimeComponentsBean.reset}"
                         value="Завершить работу с задачей"
                         styleClass="btn btn-info"/>

        <p class="text-warning" style="font-size: 11px">* без сохранения результатов</p>
    </h:form>


</div>

<br/>

<p style="font-size: 42px; padding-top: 400px" class="pagination-centered">Состав преступления</p>

<br/>
<br/>

<h:form id="crimedetailsform">

<div class="row">
<div class="span12">
<div class="row">
<div class="span6">
    <p style="font-size: 30px">Объект преступления</p>
    <br/>

    <div style="height: 370px">
        <div class="well" style="background-color: white">

            <h:panelGroup id="mainobjectdetails">

                <p style="font-size: 20px">Основной объект (обязательно)</p>

                <br/>

                <h:selectOneMenu value="#{crimeComponentsBean.mainCrimeObjectCodeName}">
                    <f:selectItems value="#{crimeComponentsBean.possibleMainCrimeObjects}"
                                   var="mainObj"
                                   itemLabel="#{mainObj.textualValue}"
                                   itemValue="#{mainObj.codeName}"/>
                </h:selectOneMenu>

            </h:panelGroup>

            <br/>
            <br/>

            <h:panelGroup id="facultativeobjectdetails">

                <p style="font-size: 20px">Факультативный объект</p>

                <h:commandButton
                        rendered="#{not crimeComponentsBean.withFacultativeCrimeObject}"
                        value="добавить"
                        styleClass="btn btn-mini">

                    <f:ajax execute="@form"
                            listener="#{crimeComponentsBean.addFacultativeCrimeObject}"
                            render="facultativeobjectdetails facultativeobjectoptions"/>

                </h:commandButton>

                <br/>

                <h:panelGroup id="facultativeobjectoptions">

                    <h:panelGroup rendered="#{crimeComponentsBean.withFacultativeCrimeObject}">

                        <h:selectOneMenu
                                value="#{crimeComponentsBean.facultativeObjectCodeName}">
                            <f:selectItems
                                    value="#{crimeComponentsBean.possibleFacultativeCrimeObjects}"
                                    var="facObj"
                                    itemLabel="#{facObj.textualValue}"
                                    itemValue="#{facObj.codeName}"/>
                        </h:selectOneMenu>

                    </h:panelGroup>

                </h:panelGroup>

            </h:panelGroup>

            <br/>
            <br/>

            <h:panelGroup id="supplementaryobjectdetails">

                <p style="font-size: 20px"
                        >Дополнительный объект (обязательно присутствует для некоторых составов)</p>

                <h:commandButton
                        rendered="#{not crimeComponentsBean.withSupplementaryCrimeObject}"
                        value="добавить"
                        styleClass="btn btn-mini">

                    <f:ajax execute="@form"
                            listener="#{crimeComponentsBean.addSupplementaryCrimeObject}"
                            render="supplementaryobjectdetails supplementaryobjectoptions"/>

                </h:commandButton>

                <br/>

                <h:panelGroup id="supplementaryobjectoptions">

                    <h:panelGroup
                            rendered="#{crimeComponentsBean.withSupplementaryCrimeObject}">

                        <h:selectOneMenu
                                value="#{crimeComponentsBean.supplementaryObjectCodeName}">
                            <f:selectItems
                                    value="#{crimeComponentsBean.possibleSupplementaryCrimeObjects}"
                                    var="supObj"
                                    itemLabel="#{supObj.textualValue}"
                                    itemValue="#{supObj.codeName}"/>
                        </h:selectOneMenu>

                    </h:panelGroup>

                </h:panelGroup>

            </h:panelGroup>

        </div>
    </div>
    <br/>
    <br/>

    <p style="font-size: 30px">Объективная сторона</p>
    <br/>

    <div style="height: 370px">
        <div class="well" style="background-color: white">

            <h:panelGroup id="criminal-act">

                <p style="font-size: 20px">Преступное деяние</p>


                <h:selectOneMenu value="#{crimeComponentsBean.criminalActCodename}">
                    <f:selectItems value="#{crimeComponentsBean.possibleCriminalActs}"
                                   var="ca"
                                   itemLabel="#{ca.textualValue}"
                                   itemValue="#{ca.codeName}"/>
                </h:selectOneMenu>

            </h:panelGroup>

            <br/>

            <h:panelGroup id="act-feature">

                <p style="font-size: 20px">Признак деяния</p>


                <h:selectOneMenu value="#{crimeComponentsBean.actFeatureCodename}">
                    <f:selectItems value="#{crimeComponentsBean.possibleActFeatures}"
                                   var="af"
                                   itemLabel="#{af.textualValue}"
                                   itemValue="#{af.codeName}"/>
                </h:selectOneMenu>

            </h:panelGroup>

        </div>
    </div>


</div>

<div class="span6">
<p style="font-size: 30px">Субъект преступления</p>
<br/>

<div style="height: 370px">
    <div class="well" style="background-color: white">

        <h:panelGroup id="subjectdetails">

            <p style="font-size: 20px">Субъект</p>

            <br/>

            <h:selectOneMenu value="#{crimeComponentsBean.crimeSubjectCodename}">
                <f:selectItems value="#{crimeComponentsBean.possibleCrimeSubjects}"
                               var="subj"
                               itemLabel="#{subj.textualValue}"
                               itemValue="#{subj.codeName}"/>
            </h:selectOneMenu>

        </h:panelGroup>

    </div>

    <br/>

    <p style="font-size: 30px">Последствия преступления</p>
    <br/>

    <h:panelGroup id="consequencedetails">

        <div class="well" style="background-color: white">

            <br/>

            <h:selectOneMenu value="#{crimeComponentsBean.crimeConsequenceCodename}">
                <f:selectItems value="#{crimeComponentsBean.possibleCrimeConsequences}"
                               var="cons"
                               itemLabel="#{cons.textualValue}"
                               itemValue="#{cons.codeName}"/>
            </h:selectOneMenu>

        </div>

    </h:panelGroup>

</div>

<br/>

<p style="font-size: 30px">Субъективная сторона преступления</p>
<br/>

<div class="well" style="background-color: white">

    <h:panelGroup id="subjectivesidedetails">

        <h:panelGroup id="chooseguilttype" rendered="#{!crimeComponentsBean.guiltTypeChosen}">

            <p style="font-size: 20px">Вина (выберите тип вины)</p>

            <br/>

            <h:commandButton
                    value="умысел"
                    styleClass="btn btn-large btn-mini">

                <f:ajax execute="@form"
                        listener="#{crimeComponentsBean.chooseGuiltTypeIntent}"
                        render="subjectivesidedetails"/>

            </h:commandButton>

            <h:commandButton
                    value="неосторожность"
                    styleClass="btn btn-large btn-mini">

                <f:ajax execute="@form"
                        listener="#{crimeComponentsBean.chooseGuiltTypeIndiscretion}"
                        render="subjectivesidedetails"/>

            </h:commandButton>

        </h:panelGroup>

        <h:panelGroup id="intentdetails" rendered="#{crimeComponentsBean.withIntent}">

            <div>
                <p style="font-size: 20px">Вина (умысел): </p>

                <br/>

                <h:selectOneMenu value="#{crimeComponentsBean.intentCodename}">
                    <f:selectItems value="#{crimeComponentsBean.possibleIntents}"
                                   var="in"
                                   itemLabel="#{in.textualValue}"
                                   itemValue="#{in.codeName}"/>
                </h:selectOneMenu>

            </div>

        </h:panelGroup>

        <h:panelGroup id="indiscretiondetails" rendered="#{crimeComponentsBean.withIndiscretion}">

            <div>

                <p style="font-size: 20px">Вина (неосторожность): </p>

                <br/>

                <h:selectOneMenu value="#{crimeComponentsBean.indiscretionCodename}">
                    <f:selectItems value="#{crimeComponentsBean.possibleIndiscretions}"
                                   var="ind"
                                   itemLabel="#{ind.textualValue}"
                                   itemValue="#{ind.codeName}"/>
                </h:selectOneMenu>

            </div>

        </h:panelGroup>

        <br/>
        <br/>

        <h:panelGroup id="motive">

            <p style="font-size: 20px">Мотив</p>

            <h:commandButton
                    rendered="#{not crimeComponentsBean.withMotive}"
                    value="добавить"
                    styleClass="btn btn-mini">

                <f:ajax execute="@form"
                        listener="#{crimeComponentsBean.addMotive}"
                        render="motive"/>

            </h:commandButton>

            <br/>

            <h:panelGroup id="motiveoptions">

                <h:panelGroup rendered="#{crimeComponentsBean.withMotive}">

                    <h:selectOneMenu
                            value="#{crimeComponentsBean.motiveCodename}">
                        <f:selectItems
                                value="#{crimeComponentsBean.possibleMotives}"
                                var="m"
                                itemLabel="#{m.textualValue}"
                                itemValue="#{m.codeName}"/>
                    </h:selectOneMenu>

                </h:panelGroup>

            </h:panelGroup>

        </h:panelGroup>

        <br/>
        <br/>

        <h:panelGroup id="purpose">

            <p style="font-size: 20px">Цель</p>

            <h:commandButton
                    rendered="#{not crimeComponentsBean.withPurpose}"
                    value="добавить"
                    styleClass="btn btn-mini">

                <f:ajax execute="@form"
                        listener="#{crimeComponentsBean.addPurpose}"
                        render="purpose"/>

            </h:commandButton>

            <br/>

            <h:panelGroup id="purpoptions">

                <h:panelGroup rendered="#{crimeComponentsBean.withPurpose}">

                    <h:selectOneMenu
                            value="#{crimeComponentsBean.purposeCodename}">
                        <f:selectItems
                                value="#{crimeComponentsBean.possiblePurposes}"
                                var="p"
                                itemLabel="#{p.textualValue}"
                                itemValue="#{p.codeName}"/>
                    </h:selectOneMenu>

                </h:panelGroup>

            </h:panelGroup>

        </h:panelGroup>

        <br/>
        <br/>

        <h:panelGroup id="delstate">

            <p style="font-size: 20px">Состояние виновного</p>

            <h:commandButton
                    rendered="#{not crimeComponentsBean.withDelinquentState}"
                    value="добавить"
                    styleClass="btn btn-mini">

                <f:ajax execute="@form"
                        listener="#{crimeComponentsBean.addDelinquentStatr}"
                        render="delstate"/>

            </h:commandButton>

            <br/>

            <h:panelGroup id="dsoptions">

                <h:panelGroup rendered="#{crimeComponentsBean.withDelinquentState}">

                    <h:selectOneMenu
                            value="#{crimeComponentsBean.delinquentStateCodename}">
                        <f:selectItems
                                value="#{crimeComponentsBean.possibleStates}"
                                var="ds"
                                itemLabel="#{ds.textualValue}"
                                itemValue="#{ds.codeName}"/>
                    </h:selectOneMenu>

                </h:panelGroup>

            </h:panelGroup>

        </h:panelGroup>


    </h:panelGroup>

    <div/>

</div>
</div>
</div>
</div>
</div>

<br/>
<h:commandButton
        styleClass="btn btn-large btn-success btnfont"
        value="Результат"
        action="#{crimeComponentsBean.submitCrimeDetails}"></h:commandButton>

&#160;

<h:commandButton
        styleClass="btn btn-large btnfont btn-warning"
        value="Сбросить"
        action="#{crimeComponentsBean.reset}">

</h:commandButton>

</h:form>

</div>
</h:panelGroup>

<h:panelGroup id="results" rendered="#{crimeComponentsBean.solutionSubmitted}">
    <div class="container">
        <p style="font-size: 45px" class="pagination-centered">Результат</p>
        <br/>
        <br/>

        <div class="alert alert-info">
            <p><strong>&#160;&#160;Задача №#{crimeComponentsBean.task.taskId}</strong>
                <br/>
                <br/>
                &#160;&#160;&#160;&#160;#{crimeComponentsBean.task.taskText}</p>
        </div>

        <br/>

        <div class="alert alert-success">
            <p class="pagination-centered"><strong>Состав преступления определен верно на
                #{crimeComponentsBean.rightPercentage}%</strong></p>
            Ваш выбор: <br/><br/>
            <ui:repeat value="#{crimeComponentsBean.submittedDetailsInfo}" var="sdi">
                <p>${sdi}<br/></p>
            </ui:repeat>
        </div>

        <br/>


        <p style="font-size: 30px; margin-left: 20px;">Подробный результат</p>
        <br/>

        <div class="span6 well" style="background-color: #ffffff">

            <ui:repeat value="#{crimeComponentsBean.verboseResult}" var="res">

                <h:panelGroup rendered="#{crimeComponentsBean.decisionIsCorrect(res)}">
                    <p class="text-success">${res}<br/></p>
                </h:panelGroup>

                <h:panelGroup rendered="#{not crimeComponentsBean.decisionIsCorrect(res)}">
                    <p class="text-error">${res}<br/></p>
                </h:panelGroup>

            </ui:repeat>

        </div>

    </div>
</h:panelGroup>

</h:body>

</f:view>
</html>